package org.thanos.simulator.enums;

import java.util.Arrays;

public enum Qos {

    QoS0(0, "At most once", "至多一次"),
    QoS1(1, "At least once", "至少一次"),
    QoS2(1, "Exactly once", "确保只有一次");

    Qos(Integer id, String code, String desc) {
        this.id = id;
        this.code = code;
        this.desc = desc;
    }

    private final Integer id;
    private final String code;
    private final String desc;

    public Integer getId() {
        return id;
    }

    public String getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    public static Qos descOf(String desc) {
        return Arrays.stream(Qos.values()).filter(qos -> qos.getDesc().equals(desc)).findAny().orElse(null);
    }
}
